import { wxRequest } from '../../utils/server.js';
const _wxRequest = new wxRequest();
const app = getApp()
Page({
  data: {
    imgUrl: app.globalData.imgUrl,
    uploadUrl: wx.getStorageSync('uploadUrl'),
    id: null,
    showModal: false
  },


  onLoad: function (options) {
    console.log(options, 'options')
    if (options.id) {
      this.setData({
        id: options.id
      })
    }

    this.contentImgs = this.selectComponent("#contentImgs");
    this.contentVideo = this.selectComponent("#contentVideo")
  },
  onShow: function () {
    this.getdetail()
  },


  //选择介绍图片
  choosecontentImgs: function (e) {
    this.setData({
      imgs: this.contentImgs.data.imgs
    })
  },

  deletecontentImgs: function (e) {
    this.setData({
      imgs: this.contentImgs.data.imgs
    })
  },

  delorigincontentImgs: function () {
    this.setData({
      originImgs: this.contentImgs.data.originImgs
    })
  },


  //介绍视频回调
  contentVideoCallback: function () {
    this.setData({
      contentVideo: this.contentVideo.data.video
    })
  },



  //获取详情
  getdetail: function () {
    _wxRequest.wxTonkenAjax({
      url: app.globalData.apiUrl + '/odr/protected/order/detail?id=' + this.data.id,
      method: 'POST',
    }, (res) => {
      var resVo = res.vo
      if (typeof resVo.detailJson == 'string') {
        resVo.detailJson = JSON.parse(resVo.detailJson)
      }
      this.setData({
        detail: resVo
      })
    })
  }

})